//
//  BookingPayTableViewCell.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/10/18.
//

import UIKit

class BookingPayTableViewCell: UITableViewCell {
    var bgView: UIView!
    var bgLayer1:CALayer!
    var titleLab: UILabel!
    var priceLab: UILabel!
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .white
        self.clipsToBounds = true
        self.initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        
        
        self.bgView = UIView(frame: .zero)
        self.bgView.backgroundColor = .white
        self.bgView.layer.cornerRadius = 8
        self.bgView.clipsToBounds = false
        
        bgLayer1 = CALayer()
        bgLayer1.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
        self.bgView.layer.addSublayer(bgLayer1)
        // shadowCode
        self.bgView.layer.shadowColor = UIColor(red: 0.96, green: 0.96, blue: 0.98, alpha: 0.9).cgColor
        self.bgView.layer.shadowOffset = CGSize(width: 0, height: 0)
        self.bgView.layer.shadowOpacity = 1
        self.bgView.layer.shadowRadius = 10
        self.contentView.addSubview(bgView)

      
        
        self.titleLab = UILabel(frame: .zero)
        self.titleLab.textColor = Theme.titleLabColor
        self.titleLab.font = UIFont.init(name: Theme.PingFangSCMedium, size: 14)
        self.titleLab.textAlignment = .center
        self.bgView.addSubview(self.titleLab)
        
        
        self.priceLab = UILabel(frame: .zero)
        self.priceLab.textColor = Theme.mainColor
        self.priceLab.font = UIFont.init(name: Theme.PingFangSCMedium, size: 24)
        self.priceLab.textAlignment = .center
        self.bgView.addSubview(self.priceLab)
        
        self.addLayout()
        
    }
    
    
    
    func addLayout(){
        
        self.bgView.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.left.equalTo(14)
            make.right.equalTo(-14)
            make.height.equalTo(100)
            make.bottom.equalTo(-10)
        }
        
        bgLayer1.frame = bgView.bounds
        
        self.titleLab.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(14)
            make.right.equalTo(-14)
            make.height.equalTo(20)
        }
        
      
        
        self.priceLab.snp.makeConstraints { make in
            make.top.equalTo(self.titleLab.snp.bottom).offset(4)
            make.left.equalTo(14)
            make.right.equalTo(-14)
            make.height.equalTo(33)
        }
        
    }
    
    
    
    //setModel
    func setModel(model: CarDetailsContentModel){
        self.titleLab.text = MMLocalizedString("booking_payment", comment: "预订支付")
        let orderPrice = XTManageCenter.showPriceInComma(source: (model.orderPrice ?? 0).cleanZero)
        self.priceLab.text = XTManageCenter.currentSign() + orderPrice
        self.updateConstraints()
    }
    
  
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
